//
//  WmcTopImgBottomTextBtn.swift
//  YPWatermarkCamera
//
//  Created by 赵新 on 2022/3/1.
//

import UIKit

class WmcTopImgBottomTextBtn: WmcImgTextControl {
    override func config() {
        label.textAlignment = .center
    }

    /// 进行布局
    override func layoutImgText() {
        imageView.snp.remakeConstraints { make in
            make.top.equalTo(contentEdge.top)
            make.left.equalTo(contentEdge.left)
            make.right.equalTo(-contentEdge.right)
            if let imgSize = imgSize {
                make.height.equalTo(imgSize)
            } else {
                make.bottom.equalTo(label.snp.top).offset(-imgTextSpacing)
            }
        }

        label.snp.remakeConstraints { make in
            make.left.equalTo(contentEdge.left)
            make.right.equalTo(-contentEdge.right)
            make.bottom.equalTo(-contentEdge.bottom)
            if let _ = imgSize {
                make.top.equalTo(imageView.snp.bottom).offset(imgTextSpacing)
            }
        }
    }
    
    

    /// 通用创建首页顶部栏的按钮
    static func CreateHomeHeaderBtn(title: String, image: UIImage) -> WmcTopImgBottomTextBtn {
        let btn = WmcTopImgBottomTextBtn(title: title, image: image)
        btn.font = 12.wmc_font
        btn.imgTextSpacing = 2
        btn.imgSize = 24
        return btn
    }
}
